package cn.sc.summer.calculate.controller;

import cn.sc.summer.calculate.form.GetLogPageForm;
import cn.sc.summer.calculate.form.GetSmsLogPageForm;
import cn.sc.summer.calculate.form.GetSysTaskLogForm;
import cn.sc.summer.calculate.service.GatewayLogService;
import cn.sc.summer.calculate.service.SmsLogService;
import cn.sc.summer.calculate.service.SysLogService;
import cn.sc.summer.calculate.service.SysTaskLogService;
import cn.sc.summer.calculate.vo.GatewayLogVO;
import cn.sc.summer.calculate.vo.SmsLogVO;
import cn.sc.summer.calculate.vo.SysLogVO;
import cn.sc.summer.calculate.vo.SysTaskLogVO;
import cn.sc.summer.constant.model.PageResult;
import cn.sc.summer.constant.model.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 类名：日志管理控制层
 *
 * @author a-xin
 * @date 2023/11/27 08:17
 */
@Slf4j
@RestController
@RequestMapping("/log")
@Api(tags = "log-日志管理控制层")
public class LogController {

    @Resource
    private GatewayLogService gatewayLogService;

    @Resource
    private SysLogService sysLogService;

    @Resource
    private SmsLogService smsLogService;

    @Resource
    private SysTaskLogService sysTaskLogService;

    @PostMapping("/getGatewayLog")
    @ApiOperation(value = "分页获取网关访问日志")
    public Result<PageResult<GatewayLogVO>> getGatewayLog(@RequestBody GetLogPageForm form) {
        return Result.success(gatewayLogService.getGatewayLog(form));
    }

    @PostMapping("/getSysLog")
    @ApiOperation(value = "分页获取API访问日志")
    public Result<PageResult<SysLogVO>> getSysLog(@RequestBody GetLogPageForm form) {
        return Result.success(sysLogService.getSysLog(form));
    }

    @PostMapping("/getSmsLog")
    @ApiOperation(value = "分页获取短信下发日志")
    public Result<PageResult<SmsLogVO>> getSmsLog(@RequestBody GetSmsLogPageForm form) {
        return Result.success(smsLogService.getSmsLog(form));
    }

    @PostMapping("/getSysTaskLog")
    @ApiOperation(value = "分页获取定时任务执行日志")
    public Result<PageResult<SysTaskLogVO>> getSysTaskLog(@RequestBody GetSysTaskLogForm form) {
        return Result.success(sysTaskLogService.getSysTaskLog(form));
    }

}
